package com.ysqcould.web.controller.members;


import com.ysqcould.common.annotation.Log;
import com.ysqcould.common.core.controller.BaseController;
import com.ysqcould.common.core.domain.AjaxResult;
import com.ysqcould.common.core.page.TableDataInfo;
import com.ysqcould.common.enums.BusinessType;
import com.ysqcould.common.utils.poi.ExcelUtil;
import com.ysqcould.members.domain.Automatic;
import com.ysqcould.members.service.IAutomaticService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 自动认证会员数据Controller
 * 
 * @author ruoyi
 * @date 2022-06-29
 */
@RestController
@RequestMapping("/members/automatic")
public class AutomaticController extends BaseController
{
    @Autowired
    private IAutomaticService automaticService;

    /**
     * 查询自动认证会员数据列表
     */
    @PreAuthorize("@ss.hasPermi('members:automatic:list')")
    @GetMapping("/list")
    public TableDataInfo list(Automatic automatic)
    {
        startPage();
        List<Automatic> list = automaticService.selectAutomaticList(automatic);
        return getDataTable(list);
    }

    /**
     * 导出自动认证会员数据列表
     */
    @PreAuthorize("@ss.hasPermi('members:automatic:export')")
    @Log(title = "自动认证会员数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Automatic automatic)
    {
        List<Automatic> list = automaticService.selectAutomaticList(automatic);
        ExcelUtil<Automatic> util = new ExcelUtil<Automatic>(Automatic.class);
        util.exportExcel(response, list, "自动认证会员数据数据");
    }

    /**
     * 获取自动认证会员数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('members:automatic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(automaticService.selectAutomaticById(id));
    }

    /**
     * 新增自动认证会员数据
     */
    @PreAuthorize("@ss.hasPermi('members:automatic:add')")
    @Log(title = "自动认证会员数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Automatic automatic)
    {
        automatic.setAsId(getUserId());
        return toAjax(automaticService.insertAutomatic(automatic));
    }

    /**
     * 修改自动认证会员数据
     */
    @PreAuthorize("@ss.hasPermi('members:automatic:edit')")
    @Log(title = "自动认证会员数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Automatic automatic)
    {
        return toAjax(automaticService.updateAutomatic(automatic));
    }

    /**
     * 删除自动认证会员数据
     */
    @PreAuthorize("@ss.hasPermi('members:automatic:remove')")
    @Log(title = "自动认证会员数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(automaticService.deleteAutomaticByIds(ids));
    }
}
